function loginApi(data) {
  // let md5Password = CryptoJS.MD5(data.password);
  // data.password = md5Password.toString(CryptoJS.enc.Base64);
  return $axios({
    'url': '/user/login',
    'method': 'post',
    data
  })
}

function logoutApi(){
  return $axios({
    'url': '/user/logout',
    'method': 'post',
  })
}

function edit_pwdApi(edit_pwdForm) {
    return axios({
        url: '/edit_pwd', // 确保这个路径正确
        method: 'POST', // 确保请求方法是正确的
        headers: {
            'Content-Type': 'application/json'
        },
        data: {
            email: edit_pwdForm.email,
            username: edit_pwdForm.username,
            password: edit_pwdForm.password
        }
    })
    .then(response => {
        return response.data; // 返回响应数据
    })
    .catch(error => {
        console.error("API 请求错误:", error);
        throw error; // 抛出错误
    });
}



function registerApi(registerForm) {
  return axios({
      url: '/register',
      method: 'post',
      headers: {
          'Content-Type': 'application/json' // 确保请求头设置为 JSON
      },
      data: {
          name: registerForm.name,
          username: registerForm.username,
          password: registerForm.password
      }
  })
  .then(response => {
      return response.data; // 返回响应数据
  })
  .catch(error => {
      console.error("注册请求错误:", error);
      throw error; // 抛出错误以便其他地方处理
  });
}